package de.oszimtcc.timetableservices;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import de.oszimtcc.framework.Logger;
import de.oszimtcc.timetable.TimetableApplication;
import de.oszimtcc.timetable.TimetableBaseScreen;

public class OnAlarmReceiver extends BroadcastReceiver 
{
	 public void onReceive(Context context, Intent intent) 
	 {	   
		 try 
		 {
			 //Toast.makeText(context, "Alarm received :" + intent.getExtras().get("message") + "\n App : " + TimetableApplication.getInstance().getActivity() + " \n Context : " + context.toString(), Toast.LENGTH_SHORT).show();
			 Logger.Debug("OnAlarmReceiver got intent : " + intent.toString() + "["+context+"]");
			 Bundle bundle = intent.getExtras();
		     String message = bundle.getString("message");
		     Intent newIntent = new Intent(context, TimetableBaseScreen.class);
		     newIntent.putExtra("message", message);
		     newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		     //context.startActivity(newIntent);
		  } 
		 catch (Exception e) 
		  {
		     Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
		  }
	}
}
